package com.atstudy.headline.web.app.service.impl;

import com.atstudy.headline.entity.Comments;
import com.atstudy.headline.web.app.mapper.CommentsMapper;
import com.atstudy.headline.web.app.service.CommentsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentsServiceImpl
        extends ServiceImpl<CommentsMapper, Comments>  // 关键修复：继承MyBatis Plus的基类
        implements CommentsService {

    @Autowired
    private CommentsMapper commentsMapper;

    @Override
    public List<Comments> list() {
        return commentsMapper.selectList(null);
    }

    @Override
    public List<Comments> listByContentId(Integer contentId) {
        if (contentId != null) {
            return commentsMapper.getCommentsByContentId(contentId);
        }
        return null;
    }

    // 不再需要手动实现saveBatch()方法
    // ServiceImpl基类已提供默认实现
}
